$(function() {
	var $result = $('#events-result');
	var id = 0, getRows = function() {
		var rows = [];
		for ( var i = 0; i < 10; i++) {
			rows.push({
				id : id,
				fdWxOpenId : 'fdWxOpenId' + id,
				docCreateTime : 'docCreateTime' + id
			});
			id++;
		}
		return rows;
	},
	// init table use data
	$table = $('#events-table').bootstrapTable({
		data : getRows()
	});
	$('#refresh-data').click(function() {
		$table.bootstrapTable('refresh', {
			url : i1510.contextPath + "/admin/mflowTpl/jqList.do"
		});
	});

	$('#remove-data').click(function() {
		var selects = $table.bootstrapTable('getSelections');
		ids = $.map(selects, function(row) {
			return row.docId;
		});

		$table.bootstrapTable('remove', {
			field : 'docId',
			values : ids
		});

	});

	$('#get-selections').click(
			function() {
				alert('Selected values: '
						+ JSON
								.stringify($table
										.bootstrapTable('getSelections')));
			});
	$('#edit-data').click(
			function() {

				var selects = $table.bootstrapTable('getSelections');
				ids = $.map(selects, function(row) {
					return row.docId;
				});
				if (ids.length != 1) {
					$result.removeClass("alert-info");
					$result.addClass("alert-danger");
					$result.text("提示:只能选择一条数据进行修改!");
				} else {
					$result.removeClass("alert-danger");
					$result.addClass("alert-info");
					$result.text("提示!");
					window.open(i1510.contextPath
							+ "/wx/mflow/gzh_edit.jsp?id=" + ids[0],
							"gzh_edit");
				}
			});
	$('#add-data').click(
			function() {
				var selects = $table.bootstrapTable('getSelections');
				ids = $.map(selects, function(row) {
					return row.docId;
				});
				window.open(i1510.contextPath
						+ "/wx/mflow/mflow_tpl_edit.jsp?menu=mFlow_tpl", "_add");
			});

});